package cloud.tianai.captcha.spring.common.util;

import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
import org.springframework.web.context.request.RequestAttributes;

import java.lang.reflect.Method;

/**
 * @Author: 天爱有情
 * @date 2023/9/14 14:10
 * @Description request 工具包
 */
public class RequestUtils {



    public static Object getRequest(RequestAttributes requestAttributes) {
        // 兼容 javax 和 jakarta
        Method method = ClassUtils.getMethod(requestAttributes.getClass(), "getRequest");
        Object request = ReflectionUtils.invokeMethod(method, requestAttributes);
        return request;
    }
}
